<!--
 * @Description:
 * @Author 卞鹏飞 <228443632@qq.com>
 * @create 2023/12/29 15:56
 -->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Title</title>
  </head>
  <body>
    <script src="./lib/index.umd.js"></script>
    <script>
			let tree = [
				{
					id: 1,
					name: '香蕉',
					pId: null,
					order: 10,
					children: [
						{
							id: 1001,
							name: '香蕉A',
							pId: 1,
							children: [
								{
									id: 1001001,
									name: '香蕉A-儿子',
									pId: 1001,
									children: [
										{
											id: 1001001001,
											name: '香蕉A-儿子-儿子',
											pId: 1001001
										}
									]
								}
							]
						},
						{
							id: 1002,
							name: '香蕉B',
							pId: 1,
							order: 21,
							children: [
								{
									id: 1002002,
									name: '香蕉B-儿子',
									pId: 1002
								}
							]
						},
						{
							id: 1003,
							name: '香蕉C',
							pId: 1,
							order: 3,
							children: [
								{
									id: 1003003,
									name: '香蕉C-儿子',
									pId: 1003
								}
							]
						}
					]
				},
				{
					id: 2,
					name: '苹果',
					pId: null,
					order: 2,
					children: [
						{
							id: 1004,
							name: '苹果A',
							pId: 2,
							children: [
								{
									id: 1004004,
									name: '苹果A-儿子',
									pId: 1004
								}
							]
						},
						{
							id: 1007,
							name: '苹果D',
							order: 5,
							pId: 2
						},
						{
							id: 1008,
							name: '苹果D',
							order: 15,
							pId: 2
						},
						{
							id: 1009,
							name: '苹果C',
							order: 10,
							pId: 2
						}
					]
				}
			]

      // 根据callbackFn自定义格式化方法，排序
      sfutils.eachTree({
        tree: tree,
        props: { children: 'children',  },
				traversalOrder: 'postorder',
        callbackItem: (item, index, list, parentObj) => {
          // item：当前节点对象 parentObj：父节点对象
          console.log('回调函数@callbackItem', item, index, list, parentObj)
        }
      })
    </script>
  </body>
</html>
